# 引入math模块
import math

# 求一元二次方程的根
def yer(a,b,c):
    x1 = (-b+ math.sqrt(b**2 - 4*a*c)) / 2*a
    x2 = (-b- math.sqrt(b**2 - 4*a*c)) / 2*a
    return x1,x2
# print(yer(7,1,-2))

# 求n的阶乘
def fn(n):
    if n==1:
        return 1
    return n * fn(n-1)
# print(fn(100))

# 找list中最值 原生方法
# enumerate()转换为索引数组
list = [4,5,8,12,323,4,56,78]
def limit(list):
    if not list:
        return (None,None)
    else:
        max = list[0]
        min = list[-1]
        for e in (list):
            if e>max:
                max = e
            elif e<min:
                min = e
        return (min,max)
res = limit(list)
# print(res)
# math方法
# print(max(list))
# print(min(list))

# 列表生成式
L = [x*x for x in range(1,21) if x%2!=0]
# print(L)
# 排列组合

L1 = [x+y for x in "abc" for y in "ABC"]
# print(L1)
# ['aA', 'aB', 'aC', 'bA', 'bB', 'bC', 'cA', 'cB', 'cC']

# 斐波那契数列
def fib(n):
    m,a,b = 0,0,1
    res = [0]
    while m <= n:
       res.append(b)
       a,b = b,a+b
       m += 1
    return res

print(fib(20))